<template>
    <div class="me">
        <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>
                <strong>会员服务</strong>
            </el-breadcrumb-item>
            <el-breadcrumb-item v-if="!menu">套餐甄选</el-breadcrumb-item>
            <el-breadcrumb-item v-if="menu">我的甄选</el-breadcrumb-item>
        </el-breadcrumb>
        <div class="m-box">
            <el-card shadow="hover" v-for="(item,index) in memberDataList" :key="index"> 
                <member-com class="card-son" :money="item.money" :unit="item.time" :name="item.name" :expire="expire"/>
                <div class="btn">
                    <el-link type="primary" @click="memberShow">
                        <el-icon :size="iconSize"><Postcard /></el-icon>
                        套餐介绍
                    </el-link>
                    <el-link type="warning" @click="surplusCount">
                        <el-icon :size="iconSize"><ShoppingCart /></el-icon>
                        剩余套餐:18/份
                    </el-link>
                    <el-link type="success" @click="buySurplus">
                        <el-icon :size="iconSize"><Pointer /></el-icon>
                        点击购买
                    </el-link>
                </div>
            </el-card>
            <el-backtop :right="50" :bottom="50" target=".m-box"/>
        </div>
        <el-dialog v-model="buyVisible" title="甄选套餐">
            <img src="https://s1.ax1x.com/2023/03/10/ppulaa6.png" alt="我的二维码">
            <template #footer>
            <div class="dialog-footer">
                <el-button type="warning" @click="buyVisible = false">取消</el-button>
                <el-button type="success" @click="buyVisible = false">
                    扫码完成确认
                </el-button>
            </div>
            </template>
        </el-dialog>
    </div>
</template>

<script setup>
import MemberCom from '@/components/sonComponent/MemberCom.vue'
import {memberList} from '@/utils/commDataFun.js'
import { onMounted, reactive, ref } from 'vue'
import { Postcard, ShoppingCart,Pointer,CaretTop} from '@element-plus/icons-vue'
import { ElNotification } from 'element-plus'
let memberDataList=ref()
const iconSize=ref(20)
const buyVisible=ref(false)
const props = defineProps({
    expire: false,
    menu: true
})
if(props.expire && props.menu){
    //我的套餐
    memberDataList = ref(memberList.slice(0,5))
}else{
    // 所有套餐
    memberDataList = ref(memberList)
}


const memberShow=()=>{
    ElNotification({
        title: '套餐介绍',
        message: 'This is a success message',
        type: 'success',
    })
}
const surplusCount=()=>{
    ElNotification({
        title: '套餐余量',
        message: 'This is a warning message',
        type: 'warning',
    })
}
const buySurplus=()=>{
    buyVisible.value=true
}
</script>

<style scoed>
.me{
    width: 100%;
    height: 100%;
    /* background: linear-gradient(45deg, rgb(26, 46, 171), rgb(100, 100, 170)); */
}
.me .m-box{
    width: 100%;
    height: 97%;
    overflow-y: scroll;
    margin-top: 10px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    justify-items: center;
}
.me .m-box .el-card{
    width: 30%;
    height: 25%;
    border-radius: 8px;
    margin: 0 20px 20px 8px;
}
.m-box .btn{
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
}

</style>